
import api from '../../modules/api'

export default {
    namespaced:true,
    state:{ 
        pageSize:5,
        currentPage:1,
        total:1,
        pages:1,  
    },
    mutations:{
        //---------------------每页显示几条数据信息--------------------------------
        setPageSize(state,newData){
            state.pageSize=newData;
            state.currentPage=1
        },
        //----------------------设置当前页数---------------------------------------
        setCurrentPage(state,newData){
            state.currentPage=newData;
        },
    },
    actions:{
       //-------------------------------------获取班级信息------------------------- 
       async getClasses(context){
            const data = await api.classes.getClasses({
                pageSize:context.state.pageSize,
                currentPage:context.state.currentPage,
            });
            context.state.total = data.data.total
            return data        
       },
       //-------------------------------------新增班级信息-------------------------
       async addClasses(context,newClasses){
           const data = await api.classes.addClasses(newClasses);
           return data
       },
       //-------------------------------------删除班级信息-----------------------------
       async deleteClasses(context,_id){
           const data = await api.classes.deleteClasses(_id);
           return data
       },
       //----------------------------根据专业 _id 获取班级-------------------------
       async getClassesBySubjectsId(context,subjectsId){
            const data = await api.classes.getClassesBySubjectsId(subjectsId);
            return data
       }
    }
}
















